﻿<UserControl x:Class="VNet.VisiSuite.Controls.DowntimeGraphControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vuc="clr-namespace:VNet.VisiSuite.Controls"
             xmlns:converter="clr-namespace:VNet.VisiSuite.Common.Converters;assembly=VNet.VisiSuite.Common"
             xmlns:production="clr-namespace:VNet.VisiSuite.Common.Production;assembly=VNet.VisiSuite.Common"
             xmlns:ig="http://schemas.infragistics.com/xaml"
             mc:Ignorable="d" 
             x:Name="_this"
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <converter:InvertBooleanConverter x:Key="InvertBooleanConverter" />
        <converter:InvertBooleanVisibilityConverter x:Key="InvertBooleanVisibilityConverter" />
        <converter:IntObjectStringConverter x:Key="IntObjectStringConverter"/>
        <converter:ColorStringToColorConverter x:Key="ColorStringToColorConverter"/>

        <converter:BarMarkerConverter x:Key="BarMarkerConverter" />
        <converter:BarMarkerVisibleConverter x:Key="BarMarkerVisibleConverter" />

    </UserControl.Resources>
    <Grid DataContext="{Binding ElementName=_this}">
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Text="{Binding GraphTitle}" Foreground="{Binding TitleFontColor}" FontSize="14pt" FontWeight="Bold"  Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        <ig:XamDataChart SizeChanged="onSizeChanged" Grid.Row="1" Grid.Column="1" x:Name="_downtime_chart" 
                         Padding="0" Visibility="Visible" Brushes="{Binding Path=DowntimeBrushes}">
            <ig:XamDataChart.Axes>
                <ig:NumericXAxis x:Name="XAxis" MinimumValue="0" Interval="{Binding Path=Interval}" MaximumValue="{Binding Path=MaximumBarValue}" FontSize="14">
                    <ig:NumericXAxis.LabelSettings>
                        <ig:AxisLabelSettings FontSize="14" Foreground="{Binding Path=LabelFontColor}" />
                    </ig:NumericXAxis.LabelSettings>
                </ig:NumericXAxis>
                <ig:CategoryYAxis x:Name="YAxis" ItemsSource="{Binding Path=DowntimeDataGroupBy.ItemsSource}"
                                  Label="{}{Description}" Interval="1" MajorStrokeThickness="0" MinorStrokeThickness="0">
                    <ig:CategoryYAxis.LabelSettings>
                        <ig:AxisLabelSettings FontSize="14" Foreground="{Binding Path=LabelFontColor}" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="0 0 8 0"></ig:AxisLabelSettings>
                    </ig:CategoryYAxis.LabelSettings>
                </ig:CategoryYAxis>
            </ig:XamDataChart.Axes>
            <ig:XamDataChart.Series>
                <ig:StackedBarSeries ItemsSource="{Binding Path=DowntimeDataGroupBy, Mode=OneWay}" 
                                     ShowDefaultTooltip="False"
                                     AutoGenerateSeries="True"
                                     XAxis="{Binding ElementName=XAxis}"
                                     YAxis="{Binding ElementName=YAxis}" 
                                     IsHighlightingEnabled="True" IsTransitionInEnabled="True" 
                                             Loaded="downtimeSeriesLoaded" >
                    <ig:StackedBarSeries.MarkerTemplate>
                        <DataTemplate>
                            <Grid Width="70" Height="30" Margin="80,0,0,0" Visibility="{Binding Item, Converter={StaticResource BarMarkerVisibleConverter}}">
                                <Border CornerRadius="5" Background="{StaticResource LightDeepSkyBlueColor}" BorderBrush="{StaticResource LightDeepSkyBlueColor}" BorderThickness="0.5">
                                    <TextBlock Margin="2" Foreground="White" FontSize="10pt" 
                                                HorizontalAlignment="Center" VerticalAlignment="Center" Text ="{Binding Item, Converter={StaticResource BarMarkerConverter}}">
                                    </TextBlock>
                                </Border>
                            </Grid>
                        </DataTemplate>
                    </ig:StackedBarSeries.MarkerTemplate>
                </ig:StackedBarSeries>

            </ig:XamDataChart.Series>
        </ig:XamDataChart>

    </Grid>
</UserControl>
